package com.open.demo.mvvm.engine

import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**
 *
 * @Author: hailong.qiu hailong.qiu@xgimi.com
 * @Maintainer: hailong.qiu hailong.qiu@xgimi.com
 * @Date: 2022/2/18
 * @Copyright: 2022 www.xgimi.com Inc. All rights reserved.
 */
abstract class BaseViewModel : ViewModel(), LifecycleObserver {

    fun launchUI(block: suspend CoroutineScope.() -> Unit) = viewModelScope.launch(
        Dispatchers.Main) { block() }

}